package class202204._26_30._29;

class Solution{
    public int firstUniqChar(String s){
        if (s == null || s.length()==0){
            return -1;
        }
        int[] array = new int[26];
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            array[ch - 'a']++;
        }
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (array[ch-'a']==1){
                return i;
            }
        }
        return -1;
    }
}



public class demo20220429 {
    public static void main(String[] args) {
           String s = "loveleetcode";

    }
}
